package com.plian.system.dao.sys.per;

import com.plian.Tools.pagedata.PageData;
import com.plian.system.dao.DaoSupport;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 权限-人员-单位
 */
@Component
public class PerUserOrgDao {
    @Resource(name = "daoSupport")
    private DaoSupport dao;

    /**
     * 根据账号id查询用户单位下的权限
     * @param userId
     * @return
     * @throws Exception
     */
    public List<PageData> queryPerUserOrg(String userId) throws Exception {
     return (List<PageData>) dao.findForList("PerUserOrgMapper.queryPerUserOrg",userId);
    }

    /**
     * 根据账号id查询用户单位下的权限组
     * @param userId
     * @return
     * @throws Exception
     */
    public List<PageData> queryPerUserGroup(String userId) throws Exception {
        return (List<PageData>) dao.findForList("PerUserOrgMapper.queryPerUserGroup",userId);
    }
    /**
     * 根据账号-单位id查询用户单位下的权限组
     * @param userOrgId
     * @return
     * @throws Exception
     */
    public List<PageData> queryByUserOrgId(String userOrgId) throws Exception {
        return (List<PageData>) dao.findForList("PerUserOrgMapper.queryByUserOrgId",userOrgId);
    }

    /**
     * 企业权限配置
     * @param list
     * @throws Exception
     */
    public void PerUserOrgConfig(List<PageData> list) throws Exception {
        dao.save("PerUserOrgMapper.PerUserOrgConfig",list);
    }

    /**
     *根据用户id删除相关权限
     * @param userId
     * @throws Exception
     */
    public void del_PerUserOrg(String userId) throws Exception {
        dao.delete("PerUserOrgMapper.del_PerUserOrg",userId);
    }

    /**
     *根据用户和组织关系表id删除相关权限
     * @param userOrgId
     * @throws Exception
     */
    public void delByUserOrgId(String userOrgId) throws Exception {
        dao.delete("PerUserOrgMapper.delByUserOrgId",userOrgId);
    }

    /**
     * 根据连接查询当前用户,链接下的按钮权限
     * @param pd)
     * @return
     */
    public List<PageData> queryBtn(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PerUserOrgMapper.queryBtn",pd);

    }

    /**
     * 查询菜单树
     * @param pd
     * @return
     */
    public List<PageData> getMenu(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PerUserOrgMapper.getMenu",pd);
    }

    /**
     *根据前端路由查询用户
     * @param pd
     * @return
     * @throws Exception
     */
    public List<PageData> getUrlUser(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PerUserOrgMapper.getUrlUser",pd);
    }
}
